package ooday03;
/**
 * 引用类型数组的演示
 */
public class RefArrayDemo {
    public static void main(String[] args) {
        /*
        //声明Dog型数组dogs，包含3个元素,每个元素都是Dog类型，默认值为null
        Dog[]dogs =new Dog[3];
        //声明Chick型数组chicks ，包含3个元素，每个元素都是Chick类型，默认值为null
        Chick[] chicks =new Chick[3];
        //声明Fish型数组fishs,包含2个元素，每个元素都是Fish类型，默认值为null
        Fish[] fishs =new Fish[2];
*/
        Dog[] dogs =new Dog[3];
        dogs[0]=new Dog("小黑",21,"白");
        dogs[1]=new Dog("大黑",2,"黑");
        dogs[2]=new Dog("黑仔",1,"绿");
        Fish[]fishs=new Fish[2];
        fishs[0]=new Fish("鲈鱼",1,"黑");
        fishs[1]=new Fish("鲤鱼",1,"红");
      Chick[] chicks =new Chick[2];
      chicks[0]=new Chick("火鸡",1,"黄");
      chicks[1]=new Chick("小鸡",1,"白");
      for (int i=0;i<dogs.length;i++){
          System.out.println("狗狗的名字:"+dogs[i].name);
          dogs[i].eat();
      }
      for (int j=0;j<fishs.length;j++){
          System.out.println("鱼的名字："+fishs[j].name);
          fishs[j].swim();
      }
      for (int k=0;k<chicks.length;k++){
          System.out.println("鸡的名字："+chicks[k].name);
          chicks[k].layEggs();
      }
    }

}
// null表示空